import { EnumSchema } from '@/utils/common/types';
import { PresetColorEnum } from '@/enums/colorEnum';

//#region 出库状态
export enum OutStorgeStatusEnum {
  Apply = 0,
  RdApprove,
  Complete,
}

export class StatusEntity {
  Type: OutStorgeStatusEnum;
  /** 显示描述 */
  Display: string;
  /** 颜色 */
  Color?: PresetColorEnum | string;

  constructor(status: OutStorgeStatusEnum, color?: PresetColorEnum | string) {
    this.Type = status;
    this.Color = color;
    switch (status) {
      case OutStorgeStatusEnum.Apply:
        this.Display = '待审批';
        this.Color = this.Color ? this.Color : PresetColorEnum.Green;
        break;
      case OutStorgeStatusEnum.RdApprove:
        this.Display = '研发审批';
        this.Color = this.Color ? this.Color : PresetColorEnum.Blue;
        break;
      case OutStorgeStatusEnum.Complete:
        this.Display = '出库完成';
        this.Color = this.Color ? this.Color : PresetColorEnum.Cyan;
        break;
    }
  }
}

export function getOutStorgeStatusSchema(enableTag = true): EnumSchema[] {
  const enumSchema: EnumSchema[] = [];
  const typeEntities: StatusEntity[] = [
    new StatusEntity(OutStorgeStatusEnum.Apply),
    new StatusEntity(OutStorgeStatusEnum.RdApprove),
    new StatusEntity(OutStorgeStatusEnum.Complete),
  ];
  typeEntities.forEach((item) => {
    enumSchema.push({
      key: item.Type as number,
      label: item.Display,
      value: item.Type as number,
      tag: enableTag,
      tagColor: item.Color,
    });
  });
  return enumSchema;
}
//#endregion
